/*
 * wk_slist_types.h
 *
 *  Created on: 2012-2-25
 *      Author: tianmax
 *
 *  功能：单向链表的功能描述
 */

#ifndef __WK_SLIST__
#define __WK_SLIST__

#include "wk_slist_types.h"

/************************************************/
extern WSList* wk_slist_init(wk_element_comp comp);
extern void wk_slist_destroy_node(WPSListNode pHead);
extern void wk_slist_destroy(WSList* list);
/***********************************************/
/*给单链表设置比较器*/
extern void wk_slist_setComp(WSList* list,wk_element_comp comp);
/************************************************/
extern int wk_slist_size(WSList* list);
extern wlong_t wk_slist_count(WSList* list);
/**************************************************/
extern int wk_slist_sort(WSList* list,wk_element_comp comp);
/*************************************************/
/**
 * 负责处理下标
 */
extern int wk_slist_index(WSList* list,int index);

/**
 * 清除链表中的所有内容，使其成为一个空链表
 */
extern int wk_slist_clean(WSList* list);

/*********************************/
extern int wk_slist_insert(WSList* list,int index,WPElement data);
/********************************/
extern int wk_slist_append(WSList* list,WPElement data);
/*******************************//**
 * 删除比较结果相同的所有元素
 */
extern int wk_slist_remove(WSList* list,WPElement data
		/*wk_slist_comp comp*/);
extern int wk_slist_removeByIndex(WSList* list,int index);
extern int wk_slist_removeFirst(WSList* list);
extern int wk_slist_removeLast(WSList* list);
/********************************/
extern WPElement wk_slist_value(WSList* list,int index);
extern WPElement wk_slist_iteratefind(WSList* list,WPElement data,
		wk_slist_iterator iterator,wk_element_iterate_do iterate_do);
extern WPElement wk_slist_find(WSList* list,WPElement data
		/*wk_slist_comp comp*/);
extern int wk_slist_findIndex(WSList* list,WPElement data
		/*wk_slist_comp comp*/);
/********************************/
/**
 * 获取当前链表指针指向位置的元素的值
 */
extern WPElement wk_slist_getcurrent(WSList* list);
/********************************/
extern int wk_slist_replaceByIndex(WSList* list,int index,WPElement data);
extern int wk_slist_replace(WSList* list,WPElement olddata,
		WPElement newdata/*wk_slist_comp comp*/);
/******************************/
extern int wk_slist_push_front(WSList* list,WPElement data);
extern int wk_slist_push_back(WSList* list,WPElement data);
/******************************/
extern void wk_slist_pop_back(WSList* list);
extern void wk_slist_pop_front(WSList* list);
/**************************************/
/**
 * 链表当前指针操作
 */
extern void wk_slist_head(WSList* list);
extern void wk_slist_begin(WSList* list);
extern void wk_slist_end(WSList* list);
extern void wk_slist_at(WSList* list,int index);
extern void wk_slist_next(WSList* list);
extern void wk_slist_prev(WSList* list);
extern int wk_slist_hasNext(WSList* list);
/*******************************/
/**
 * 遍历元素相关
 * ctx上下文
 */
extern void* wk_slist_iterate(WSList* list,wk_element_iterate_do iterate_do,void* ctx);
/****************************************************/
/**
 * wk_slist调试函数
 */
extern void wk_slist_debug();
/*****************************************************/

#endif
